<template>
    <div>
        <el-table
            v-if="!showTable"
            :data="data"
            height="calc(100vh - 230px)"
            border
            style="width: 100%"
            size="mini"
            highlight-current-row
            :header-cell-style="headerCellStyle"
            @selection-change="selectionChange"
            oncontextmenu="return false;"
            ref="multipleTable"
            empty-text="暂无数据"
            v-loading="dataLoading"
            @sort-change="onTableSort"
            show-summary
            :summary-method="getSummaries"
        >
            <el-table-column type="selection" width="38"></el-table-column>
            <el-table-column type="index" align="center" label="序号" width="55" fixed></el-table-column>
            <el-table-column prop="time" label="业务日期" header-align="center" align="center" width="100" fixed
                             sortable="custom"></el-table-column>
            <el-table-column prop="whCode" label="仓库" header-align="center" align="center" width="120" fixed
                             sortable="custom">
                <template slot-scope="scope">
                    <span>{{ $handleFormatter(scope.row.whCode, whCodeList, 'whCode', 'whName') }}</span>
                </template>
            </el-table-column>
            <el-table-column prop="ownerCode" label="货主" header-align="center" align="center" width="220"
                             :show-overflow-tooltip="true" fixed sortable="custom">
                <template slot-scope="scope">
                    <span>{{ $handleFormatter(scope.row.ownerCode, ownerCodeList, 'ownerCode', 'ownerName') }}</span>
                </template>
            </el-table-column>
            <el-table-column prop="manageCompanyCode" label="运营公司" header-align="center" align="center" width="120"
                             sortable="custom">
                <template slot-scope="scope">
                    <span>{{
                            $handleFormatter(scope.row.manageCompanyCode, manageCompanyList, 'id', 'departname')
                        }}</span>
                </template>
            </el-table-column>

            <el-table-column label="入库统计" header-align="center" align="center">
                <el-table-column prop="boxNum" label="箱量" header-align="center" align="center"
                                 sortable="custom"></el-table-column>
                <el-table-column prop="inTotalNum" label="件数" header-align="center" align="center"
                                 sortable="custom"></el-table-column>
                <el-table-column prop="inWeightNum" label="重量(KG)" header-align="center" align="center" width="100"
                                 sortable="custom"></el-table-column>
                <el-table-column prop="inTraceNum" label="托数" header-align="center" align="center"
                                 sortable="custom"></el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="90">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button v-if="scope.row.inTraceNum" size="small" type="text" style="color: #4f68e8" @click="clickNode('in', scope.row)">详情</el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

            <el-table-column label="出库统计" header-align="center" align="center">
                <el-table-column prop="outTotalNum" label="件数" header-align="center" align="center"
                                 sortable="custom"></el-table-column>
                <el-table-column prop="outWeightNum" label="重量(KG)" header-align="center" align="center" width="100"
                                 sortable="custom"></el-table-column>
                <el-table-column prop="outTraceNum" label="托数" header-align="center" align="center"
                                 sortable="custom"></el-table-column>
                <el-table-column prop="carNum" label="车数" header-align="center" align="center"
                                 sortable="custom"></el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="90">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button v-if="scope.row.outTraceNum" size="small" type="text" style="color: #4f68e8" @click="clickNode('out', scope.row)">详情</el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

        </el-table>
        <el-table
            v-else
            :data="data"
            height="calc(100vh - 230px)"
            border
            style="width: 100%"
            size="mini"
            highlight-current-row
            :header-cell-style="headerCellStyle"
            @selection-change="selectionChange"
            oncontextmenu="return false;"
            ref="multipleTable"
            empty-text="暂无数据"
            v-loading="dataLoading"
            @sort-change="onTableSort"
            show-summary
            :summary-method="getStorageDailySum"
        >
            <el-table-column type="selection" width="38"></el-table-column>
            <el-table-column type="index" align="center" label="序号" width="55"></el-table-column>
            <el-table-column prop="time" label="业务日期" header-align="center" align="center" width="100"
                             sortable="custom"></el-table-column>
            <el-table-column prop="ownerCode" label="货权方" header-align="center" align="center" width="220"
                             :show-overflow-tooltip="true" sortable="custom">
                <template slot-scope="scope">
                    <span>{{ $handleFormatter(scope.row.ownerCode, ownerCodeList, 'ownerCode', 'ownerName') }}</span>
                </template>
            </el-table-column>

            <el-table-column label="入库统计" header-align="center" align="center">
                <el-table-column prop="inPlanQty" label="单数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="inTotalNum" label="件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="inWeightNum" label="重量(KG)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="inStandardTraceNum" label="标准托数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="inTraceNum" label="实际托数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="90">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button size="small" type="text" style="color: #4f68e8" @click="clickDetails('in', scope.row)">-->
<!--                            详情-->
<!--                        </el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

            <el-table-column label="出库统计" header-align="center" align="center">
                <el-table-column prop="outPlanQty" label="单数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="outTotalNum" label="件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="outWeightNum" label="重量(KG)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="outStandardTraceNum" label="标准托数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="outTraceNum" label="实际托数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="90">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button size="small" type="text" style="color: #4f68e8" @click="clickDetails('out', scope.row)">-->
<!--                            详情-->
<!--                        </el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

            <el-table-column label="分色统计" header-align="center" align="center">
                <el-table-column prop="separatePlanQty" label="单数" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="separateTransferOutQty" label="原品转出件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="separateTransferOutWeight" label="原品转出重量(KG)" header-align="center" align="center" width="150" sortable="custom">
                </el-table-column>
                <el-table-column prop="separateTransferInQty" label="目标实际分色件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="separateTransferInWeight" label="目标实际分色重量(KG)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="separateDeliverQty" label="目标发货件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="separateDeliverWeight" label="目标发货重量(KG)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="100">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button size="small" type="text" style="color: #4f68e8" @click="clickDetails('separate', scope.row)">-->
<!--                            目标分色详情-->
<!--                        </el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

            <el-table-column label="货转转入统计" header-align="center" align="center">
                <el-table-column prop="stockTransferInQty" label="转入件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="stockTransferInWeight" label="转入重量(KG)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="90" key="slot">-->
<!--                    <template #default="scope">-->
<!--                        <el-button size="small" type="text" style="color: #4f68e8" @click="clickDetails('stockin', scope.row)">-->
<!--                            详情-->
<!--                        </el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

            <el-table-column label="货转转出统计" header-align="center" align="center">
                <el-table-column prop="stockTransferOutQty" label="转出件数(件)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
                <el-table-column prop="stockTransferOutWeight" label="转出重量(KG)" header-align="center" align="center" width="150"
                                 sortable="custom">
                </el-table-column>
<!--                <el-table-column label="操作" header-align="center" align="center" width="90">-->
<!--                    <template slot-scope="scope">-->
<!--                        <el-button size="small" type="text" style="color: #4f68e8" @click="clickDetails('stockout', scope.row)">-->
<!--                            详情-->
<!--                        </el-button>-->
<!--                    </template>-->
<!--                </el-table-column>-->
            </el-table-column>

        </el-table>
        <Row class="margin-top-10">
            <Page
                :total="total"
                :current="listQuery.pageNum"
                :page-size="listQuery.pageSize"
                :page-size-opts="listQuery.pageOptionsList"
                size="small"
                @on-change="pageChange"
                @on-page-size-change="pageSizeChange"
                show-elevator
                show-sizer
            ></Page>
        </Row>
    </div>
</template>

<script>
import {
    exportWareDataList,
    getDailySumData,
    exportStorageDaily,
    getStorageDaily,
    exportAllDataList
} from '@/api/warehouse/home.js'; // okok
import fileDownload from 'js-file-download'; // 不确定
import timeUtil from '@/libs/timeUtil.js'
import {storageDailySearch, storageDailyData, exportStorageDailyData} from '@/api/statisticalModule.js'

export default {
    name: 'daily-table',
    data() {
        return {
            palletMixList: [],
            alleyMixList: [],
            exportLoading: false,
            data: [],
            selectDataList: [],
            dataLoading: false,
            total: 0,
            listQuery: {
                pageNum: this.$store.state.sysSettings.pageNum,
                pageSize: this.$store.state.sysSettings.pageSize,
                pageOptionsList: this.$store.state.sysSettings.pageOptionsList,
                filterList: [],
                sortList: [],
                searchKey: '',
                selectDataList: []
            },
            sumData: {},
            storageDailySum: {}
        };
    },
    computed: {
        headerCellStyle() {
            return {
                fontSize: `${12}px`,
                fontWeight: 'bold',
                color: '#8c8c90',
                backgroundColor: 'rgb(239, 243, 247)'
            };
        }
    },
    props: {
        searchParams: Object,
        whCodeList: Array,
        ownerCodeList: Array,
        manageCompanyList: Array,
        wmsUrl: String,
        showTable: Boolean
    },
    methods: {
        // 点击详情
        async clickDetails(key,row) {
            let detailkey = '';
            switch (key) {
                case 'in':
                    detailkey = '入库';
                    break;
                case 'out':
                    detailkey = '出库';
                    break;
                case 'separate':
                    detailkey = '分色';
                    break;
                case 'stockin':
                    detailkey = '货转转入';
                    break;
                case 'stockout':
                    detailkey = '货转转出';
                    break;
                default:
                    break;
            }
            window.localStorage.setItem('routerT', detailkey)
            await this.$router.push({
                path: 'dailydetails',
                query: {
                    time: row.time,
                    whCode: row.whCode,
                    ownerCode: row.ownerCode,
                    wmsUrl: this.wmsUrl,
                    key
                }
            });
        },
        loginOut() {
            this.$Modal.confirm({
                title: '提示',
                content: '网络错误！！！',
                okText: '退出系统',
                cancelText: '取消',
                onOk: () => {
                    this.$auth.logout({
                        success: function () {
                        },
                        error: function () {
                        }
                    });
                },
                onCancel: () => {
                    return false;
                }
            });
        },
        $handleFormatter(data, list, keys, name) {
            if (typeof data !== 'undefined' && data !== null && data !== '') {
                for (let i = 0; i < list.length; i++) {
                    if (data.toString() == list[i][keys]) {
                        return list[i][name];
                    }
                }
            }
        },
        down() {
            this.listQuery.selectDataList = [];
            if (this.selectDataList.length > 0) {
                this.selectDataList.forEach(item => {
                    this.listQuery.selectDataList.push(item.whCode);
                });
            }
            exportWareDataList(this.listQuery).then(response => {
                if (response.status === 200) {
                    // this.$success('操作成功');
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    fileDownload(response.data, '仓库信息.xlsx');
                }
            }).catch(err => {
                console.log(err);
            });
        },
        clickNode(val, row) {
            this.$router.push({
                path: 'ctn',
                query: {
                    type: val,
                    time: row.time,
                    whCode: row.whCode,
                    ownerCode: row.ownerCode,
                    manageCompanyCode: row.manageCompanyCode,
                    wmsUrl: this.wmsUrl
                }
            });
        },
        initGridData(searchParams, wmsUrl) {
            // if (!searchParams.ownerCodeList.length) {
            //     this.data = [];
            //     this.total = 0;
            //     return;
            // }
            this.data = [];
            this.dataLoading = true;
            searchParams.startTime = new Date(Date.parse(searchParams.date[0]) + 8 * 3600 * 1000);
            searchParams.endTime = new Date(Date.parse(searchParams.date[1]) + 8 * 3600 * 1000);
            searchParams.startTimeStr = this.$utils.dateToDateStr(searchParams.startTime);
            searchParams.endTimeStr = this.$utils.dateToDateStr(searchParams.endTime);
            console.log(searchParams);
            if (this.showTable) {
                let businessDateList = [timeUtil.timestampToDate(this.searchParams.startTime), timeUtil.timestampToDate(this.searchParams.endTime)];
                let body = {
                    pageNum: this.$store.state.sysSettings.pageNum,
                    pageSize: this.$store.state.sysSettings.pageSize,
                    ownerCodeList: searchParams.ownerCodeList,
                    businessDateList
                }
                storageDailySearch(body,this.wmsUrl).then(({data}) => {
                    if (data.returnCode === 200) {
                        this.data = data.returnData.records;
                        this.total =  data.returnData.total;
                    }
                    this.dataLoading = false;
                }).catch(err => {
                    this.dataLoading = false;
                    this.loginOut();
                });
            }else {
               getStorageDaily({ ...searchParams, ...this.listQuery }, wmsUrl).then(response => {
                    if (response.data.returnCode === 200) {
                        this.data = response.data.returnData.pageInfo.list;
                        this.total = response.data.returnData.pageInfo.total;
                    } else {
                        this.$error(response.data.returnMsg, 3);
                    }
                    this.dataLoading = false;
                }).catch(err => {
                    this.dataLoading = false;
                    this.loginOut();
                });
            }
        },
        selectionChange(selection) {
            this.selectDataList = selection;
        },
        // 排序
        onTableSort(result) {
            if (result.order === 'descending') {
                let sortItem = {
                    sortKey: result.prop,
                    sortValue: 'desc'
                };
                this.listQuery.sortList = [sortItem];
            } else if (result.order === 'ascending') {
                let sortItem = {
                    sortKey: result.prop,
                    sortValue: 'asc'
                };
                this.listQuery.sortList = [sortItem];
            } else {
                this.listQuery.sortList = [];
            }
            this.initGridData(this.searchParams, this.wmsUrl);
            this.getSumData(this.searchParams, this.wmsUrl);
        },
        // 改变页数,
        pageChange(pageNum) {
            this.listQuery.pageNum = pageNum;
            this.initGridData(this.searchParams, this.wmsUrl);
            this.getSumData(this.searchParams, this.wmsUrl);
        },
        // 改变条数
        pageSizeChange(pageSize) {
            this.listQuery.pageSize = pageSize;
            this.initGridData(this.searchParams, this.wmsUrl);
            this.getSumData(this.searchParams, this.wmsUrl);
        },
        getSummaries(param) {
            const { columns, data } = param;
            const sums = [];
            columns.forEach((column, index) => {
                if (index === 0) {
                    sums[index] = '合';
                    return;
                }
                switch (index) {
                    // case 17:
                    //   sums[index] = (sums[index] / 1000000).toFixed(4) + 'm³';
                    //   break;
                    case 6:
                        sums[index] = this.sumData.boxNumSum + '箱';
                        break;
                    case 7:
                        sums[index] = this.sumData.intoTotalSum + '件';
                        break;
                    case 8:
                        sums[index] = Number(this.sumData.intoWeightSum).toFixed(3) + 'KG';
                        break;
                    case 9:
                        sums[index] = this.sumData.intoTraceSum + '托';
                        break;
                    // case 9:
                    //   sums[index] = this.sumData.intoTeuSum + 'TEU';
                    //   break;
                    // case 10:
                    //   sums[index] = this.sumData.boxNumSum + '柜';
                    //   break;
                    // case 11:
                    //   sums[index] = this.sumData.intoTeu20Sum + '个';
                    //   break;
                    // case 12:
                    //   sums[index] = this.sumData.intoTeu40Sum + '个';
                    //   break;
                    case 10:
                        sums[index] = this.sumData.outTotalSum + '件';
                        break;
                    case 11:
                        sums[index] = Number(this.sumData.outWeightSum).toFixed(3) + 'KG';
                        break;
                    case 12:
                        sums[index] = this.sumData.outTraceSum + '托';
                        break;
                    case 13:
                        sums[index] = this.sumData.carNumSum + '车';
                        break;
                    // case 19:
                    //   sums[index] = this.sumData.checkTeuSum + 'TEU';
                    //   break;
                    // case 20:
                    //   sums[index] = this.sumData.checkTeu20Sum + '个';
                    //   break;
                    // case 21:
                    //   sums[index] = this.sumData.checkTeu40Sum + '个';
                    //   break;
                    case 16:
                        sums[index] = this.sumData.moveTotalSum + '件';
                        break;
                    case 17:
                        sums[index] = Number(this.sumData.moveWeightSum).toFixed(3) + 'KG';
                        break;
                    case 18:
                        sums[index] = this.sumData.moveTraceSum + '托';
                        break;
                    // case 25:
                    //   sums[index] = this.sumData.moveTeuSum + 'TEU';
                    //   break;
                    // case 26:
                    //   sums[index] = this.sumData.moveTeu20Sum + '个';
                    //   break;
                    // case 27:
                    //   sums[index] = this.sumData.moveTeu40Sum + '个';
                    //   break;
                    case 19:
                        sums[index] = this.sumData.stockTotalSum + '件';
                        break;
                    case 20:
                        sums[index] = Number(this.sumData.stockWeightSum).toFixed(3) + 'KG';
                        break;
                    case 21:
                        sums[index] = this.sumData.stockTraceSum + '托';
                        break;
                    // case 31:
                    //   sums[index] = this.sumData.stockTeuSum + 'TEU';
                    //   break;
                    default:
                        sums[index] = '';
                }
            });
            return sums;
        },
        getStorageDailySum({ columns, data}) {
            const sums = [];
            columns.forEach((column, index) => {
                if (index === 0) {
                    sums[index] = '合';
                    return;
                }
                switch (index) {
                    case 4:
                        sums[index] = this.storageDailySum.inPlanQty + '单';
                        break;
                    case 5:
                        sums[index] = this.storageDailySum.inTotalNum + '件';
                        break;
                    case 6:
                        sums[index] =  Number(this.storageDailySum.inWeightNum).toFixed(3) + 'KG';
                        break;
                    case 7:
                        sums[index] = this.storageDailySum.inStandardTraceNum + '托';
                        break;
                    case 8:
                        sums[index] = this.storageDailySum.inTraceNum + '托';
                        break;

                    case 10:
                        sums[index] = this.storageDailySum.outPlanQty + '单';
                        break;
                    case 11:
                        sums[index] = this.storageDailySum.outTotalNum + '件';
                        break;
                    case 12:
                        sums[index] = Number(this.storageDailySum.outWeightNum).toFixed(3) + 'KG';
                        break;
                    case 13:
                        sums[index] = this.storageDailySum.outStandardTraceNum + '托';
                        break;
                    case 14:
                      sums[index] = this.storageDailySum.outTraceNum + '托';
                      break;

                    case 16:
                        sums[index] = this.storageDailySum.separatePlanQty + '单';
                        break;
                    case 17:
                        sums[index] = this.storageDailySum.separateTransferOutQty + '件';
                        break;
                    case 18:
                        sums[index] = this.storageDailySum.separateTransferOutWeight + 'KG';
                        break;
                    case 19:
                        sums[index] = this.storageDailySum.separateTransferInQty + '件';
                        break;
                    case 20:
                        sums[index] = Number(this.storageDailySum.separateTransferInWeight).toFixed(3) + 'KG';
                        break;
                    case 21:
                        sums[index] = this.storageDailySum.separateDeliverQty + '件';
                        break;
                    case 22:
                        sums[index] = Number(this.storageDailySum.separateDeliverWeight).toFixed(3) + 'KG';
                      break;

                    case 24:
                        sums[index] = this.storageDailySum.stockTransferInQty + '件';
                        break;
                    case 25:
                        sums[index] = Number(this.storageDailySum.stockTransferInWeight).toFixed(3) + 'KG';
                      break;

                    case 27:
                        sums[index] = this.storageDailySum.stockTransferOutQty + '件';
                        break;
                    case 28:
                        sums[index] = Number(this.storageDailySum.stockTransferOutWeight).toFixed(3) + 'KG';
                      break;

                    default:
                        sums[index] = '';
                }
            });
            return sums;
        },
        getSumData(searchParams, wmsUrl) {
            // if (!searchParams.ownerCodeList.length) {
            //     this.sumData = {};
            //     this.$nextTick(() => {
            //         this.$refs['multipleTable'].doLayout();
            //     });
            //     return;
            // }
            searchParams.startTime = new Date(Date.parse(searchParams.date[0]) + 8 * 3600 * 1000);
            searchParams.endTime = new Date(Date.parse(searchParams.date[1]) + 8 * 3600 * 1000);
            if (this.showTable) {
                let businessDateList = [timeUtil.timestampToDate(this.searchParams.startTime), timeUtil.timestampToDate(this.searchParams.endTime)];
                let body = {
                    pageNum: this.$store.state.sysSettings.pageNum,
                    pageSize: this.$store.state.sysSettings.pageSize,
                    ownerCodeList: searchParams.ownerCodeList,
                    businessDateList
                }
                storageDailyData(body, wmsUrl).then(({data}) => {
                    console.log(data);
                    if (data.returnCode === 200) {
                        this.storageDailySum = data.returnData;
                        this.$nextTick(() => {
                            this.$refs['multipleTable'].doLayout();
                        });
                    } else {
                        this.$error(response.data.returnMsg, 3);
                    }
                }).catch(err => {
                    console.log(err);
                });
            }else {
                getDailySumData({ ...searchParams }, wmsUrl).then(response => {
                    if (response.data.returnCode === 200) {
                        this.sumData = response.data.returnData;
                        this.$nextTick(() => {
                            this.$refs['multipleTable'].doLayout();
                        });
                    } else {
                        this.$error(response.data.returnMsg, 3);
                    }
                }).catch(err => {
                    console.log(err);
                });
            }

        },
        exportExcel(searchParams, wmsUrl, ccisWhId) {
            console.log(searchParams, wmsUrl, ccisWhId);
            searchParams.startTime = new Date(Date.parse(searchParams.date[0]) + 8 * 3600 * 1000);
            searchParams.endTime = new Date(Date.parse(searchParams.date[1]) + 8 * 3600 * 1000);
            let response;
            if (ccisWhId === 27 || ccisWhId === 36) {
                response = exportStorageDaily({...searchParams, ...this.listQuery}, wmsUrl);
            } else if (ccisWhId === 37) {
                let businessDateList = [timeUtil.timestampToDate(this.searchParams.startTime), timeUtil.timestampToDate(this.searchParams.endTime)];
                let body = {
                    pageNum: this.$store.state.sysSettings.pageNum,
                    pageSize: this.$store.state.sysSettings.pageSize,
                    ownerCodeList: searchParams.ownerCodeList,
                    businessDateList
                }
                response = exportStorageDailyData({...searchParams, ...body}, wmsUrl);
            } else {
                response = exportAllDataList({...searchParams, ...this.listQuery}, wmsUrl);
            }
            response.then(response => {
                if (response.data.returnCode === 400) {
                    this.$Message.error(response.data.returnMs)
                } else {
                    fileDownload(response.data, '仓储业务日报.xlsx')
                }
            });
        },
        exportOut() {
            console.log(this.data);
            if (this.data.length === 0) {
                // this.$warn('暂无可导出数据', 3);
                this.$message({
                    message: '暂无可导出数据',
                    type: 'warning'
                });
                return;
            }
            exportStorageDaily({ ...this.searchParams, ...this.listQuery }).then(response => {
                if (response.data.returnCode === 400) {
                    this.$error(response.data.returnMsg, 3);
                } else {
                    // this.$success('操作成功');
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    fileDownload(response.data, '仓储业务日报.xlsx');
                }
            });
        },
        // getStorageDailySearch() {
        //     let businessDateList = [timeUtil.timestampToDate(this.searchParams.startTime), timeUtil.timestampToDate(this.searchParams.endTime)];
        //     let body = {
        //         pageNum: this.$store.state.sysSettings.pageNum,
        //         pageSize: this.$store.state.sysSettings.pageSize,
        //         ownerCodeList: [],
        //         businessDateList
        //     }
        //     storageDailySearch(body,this.wmsUrl).then(({data}) => {
        //         if (data.returnCode === 200) {
        //             this.data = data.returnData.records;
        //             this.total =  data.returnData.total;
        //         }
        //         console.log(data);
        //     }).catch((err) => {
        //         console.log(err);
        //     });
        // }
    },
    updated() {
        this.$refs['multipleTable'].doLayout();
    },
    watch: {
        showTable: {
            handler(val) {
                this.dataLoading = true;
                setTimeout(() => {
                    this.dataLoading = false;
                }, 1000);
            }
        }
    }
};
</script>

<style scoped>

</style>
